package com.ziyun.erp.web.modules.goodsMonitor.controller;

import java.util.Arrays;
import java.util.Map;

import com.netflix.discovery.converters.Auto;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.goodsMonitor.entity.GoodsMonitorEntity;
import com.ziyun.erp.modules.goodsMonitor.service.GoodsMonitorService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 商品类修改记录表
 *
 * @author xueqz
 * @email 
 * @date 2018-11-13 10:12:50
 */
@RestController
@RequestMapping("goodsMonitor/goodsmonitor")
public class GoodsMonitorController {
    @Autowired
    private GoodsMonitorService goodsMonitorService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("goodsMonitor:goodsmonitor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = goodsMonitorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("goodsMonitor:goodsmonitor:info")
    public R info(@PathVariable("id") Integer id){
        GoodsMonitorEntity goodsMonitor = goodsMonitorService.selectById(id);

        return R.ok().put("goodsMonitor", goodsMonitor);
    }

     /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("goodsMonitor:goodsmonitor:save")
    public R save(@RequestBody GoodsMonitorEntity goodsMonitor){
        goodsMonitorService.insert(goodsMonitor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("goodsMonitor:goodsmonitor:update")
    public R update(@RequestBody GoodsMonitorEntity goodsMonitor){
        ValidatorUtils.validateEntity(goodsMonitor);
        goodsMonitorService.updateAllColumnById(goodsMonitor);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("goodsMonitor:goodsmonitor:delete")
    public R delete(@RequestBody Integer[] ids){
        goodsMonitorService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
